package com.inspur.mr.parelectric;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class ElectricDriver {
	public static void main(String[] args) throws Exception {
		System.setProperty("HADOOP_USER_NAME", "hadoop");
		Configuration conf = new Configuration();
		Job job = Job.getInstance(conf,"electric");
		job.setJarByClass(ElectricDriver.class);
		job.setMapperClass(ElectricPartitionMapper.class);
		job.setMapOutputKeyClass(Text.class);
	    job.setMapOutputValueClass(Text.class);
		job.setPartitionerClass(ElectricPartition.class);
		job.setNumReduceTasks(3);
		job.setReducerClass(ElectricPartitionReducer.class);
		job.setOutputKeyClass(Text.class);
		job.setMapOutputValueClass(Text.class);
		FileInputFormat.setInputPaths(job, new Path("hdfs://192.168.56.56:24/electric.txt"));
		FileOutputFormat.setOutputPath(job, new Path("hdfs://192.168.56.56:24/out4"));
		job.waitForCompletion(true);
	}
}
